package com.example.environment.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.PropertySource;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class AdmiralConfigEnvironmentProcessor implements EnvironmentPostProcessor {
    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        MutablePropertySources propertySources = environment.getPropertySources();
        Properties properties = new Properties();
        Map<String, String> result = new HashMap<>();
        result.put("sso.cookieName", "__cookieName__");
        result.put("port", "8082");
        properties.putAll(result);
        PropertySource<?> propertiesPropertySource = new PropertiesPropertySource("dynamic", properties);
        propertySources.addLast(propertiesPropertySource);
        System.out.println("---postProcessEnvironment---");
    }
}
